import pymongo
# print(pymongo)
# print(dir(pymongo))

# 1.创建一个连接实例
client = pymongo.MongoClient(host="localhost", port=27017)
# print(client,dir(client))
# 2.切换或者创建一个数据库
db = client.get_database("wo521")
print(db, dir(db))
# 3.创建或者使用一个集合
collection = db.get_collection("students")
# print(collection, dir(collection))

# 4.查找文档
datas = collection.find(filter={"name": "ji"})
# print(datas, isinstance(datas, Iterable))
for data in datas:
    print(data)

datasad = collection.insert_many([{"name": "ji"}])
